home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / misc / BST_SystemDocs.lha / BeastV1 / Examples / B52_System / searchtest.b52 < prev    next >
Encoding:
Text File  |  1996-04-12  |  1.3 KB  |  77 lines

  1. VARIABLE Instance_Size
  2.  
  3. : Reset_Instance  0 Instance_Size ! ;
  4. : Add_Attribute Instance_Size @ DUP 4 + Instance_Size ! ;
  5. : Get_Instance  8 + @ ;
  6.  
  7. ( --- Create Class --- )
  8.  
  9. Reset_Instance
  10.  
  11. Add_Attribute CONSTANT Num
  12. Add_Attribute CONSTANT Den
  13.  
  14. "my_Search"  Instance_Size @ BST_MakeClass CONSTANT my_SearchClass
  15.  
  16. my_SearchClass "Class=" .STR . CR
  17.  
  18. ( --- Add Method --- )
  19.  
  20. my_SearchClass
  21.  
  22. :METHOD Init
  23. ( Methods are called with three parameters on stack:
  24.   pointer to a taglist, pointer to the object, and the flags. )
  25.  
  26.   CR "METHOD CALL INIT" .STR  CR
  27.  
  28. ( drop the taglist )
  29.   DROP
  30.  
  31. ( get the pointer to the data section of the object )
  32.   Get_Instance
  33.  
  34.   DUP  Num + 0 SWAP !  Den + 0 SWAP !
  35.  
  36. RETURN ;
  37.  
  38. #OBM_INIT
  39.  
  40. CLSS_AddMethod
  41.  
  42. ( ************************ )
  43. :METHOD local
  44. "** local method call" .STR CR
  45. RETURN ;
  46.  
  47. #OBM_local1 CLSS_AddMethod
  48.  
  49. my_SearchClass BST_AddClass DROP
  50.  
  51.  
  52.  
  53. ( --- Create Object --- )
  54.  
  55. 0  "my_SearchClass"  0  OBJ_NewObject   CONSTANT My_Object
  56.  
  57. My_Object "Object=" .STR . CR
  58.  
  59. ( Do something to the Object )
  60.  
  61. My_Object #OBM_INIT 0 0  OBJ_DoMethod DROP
  62.  
  63. ( ********************* )
  64. My_Object #OBM_FOREACH
  65.  
  66.  
  67. ( Get Rid of the Object )
  68.  
  69. My_Object OBJ_DisposeObject DROP
  70.  
  71. ( ------- Clean Up --------- )
  72.  
  73. my_SearchClass BST_RemoveClass DROP
  74. my_SearchClass BST_FreeClass   DROP
  75.  
  76. 0 RETURN
  77.